home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / FlyThrough 1.1.2 / src / Source / QD3D General Tools / StQD3DInitializer.cp < prev    next >
Encoding:
Text File  |  1997-05-14  |  1.1 KB  |  54 lines  |  [TEXT/CWIE]

  1. //
  2. //    StQD3DInitializer.h
  3. //
  4. //    A stack-based class to initialize and clean up a QuickDraw 3D environment.
  5. //    Declare it in main() after your toolbox initialization.
  6. //
  7. //    by James Jennings
  8. //    November 12, 1995
  9. //
  10. //    Note: The names of the gestalt codes are different 
  11. //    from what's in the documentation.
  12. //
  13.  
  14. #pragma once
  15.  
  16. #include "StQD3DInitializer.h"
  17.  
  18.  
  19. Boolean StQD3DInitializer::HasQD3D(void)
  20. {
  21. #if 1    // there are two ways to test this
  22.     long result;
  23.     OSErr err = ::Gestalt(gestaltQD3D, &result);
  24.     return (err == noErr) && (result == gestaltQD3DAvailable);
  25. #else
  26.     return ((Boolean) Q3Initialize != kUnresolvedSymbolAddress);
  27. #endif
  28. }
  29.  
  30.  
  31. StQD3DInitializer::StQD3DInitializer(void)
  32.     : status(kQ3Failure)
  33. {
  34.     if (!HasQD3D()) return;    // Throw exception?
  35.     status = ::Q3Initialize();
  36.     if (status == kQ3Failure) 
  37.         SignalPStr_("\pQuickDraw 3D is not available.");
  38. }
  39.  
  40.  
  41. StQD3DInitializer::~StQD3DInitializer(void)
  42. {
  43.     if (status==kQ3Success)
  44.         status = ::Q3Exit();
  45. //    if (status == kQ3Failure) // Throw exception?
  46. }
  47.  
  48.  
  49. TQ3Status StQD3DInitializer::GetStatus(void)
  50. {
  51.     return status;
  52. }
  53.  
  54.